package com.wuyancheng.blog.service;

import com.wuyancheng.blog.mapper.ArticleMapper;
import com.wuyancheng.blog.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleService {

    @Autowired
    private ArticleMapper articleMapper;

    /**
     * 根据页数，和size查询当前页信息
     * @param pageNum
     * @param pageSize
     * @return
     */
    public List<Article> queryArticle(int pageNum, int pageSize){
        List<Article> articles = articleMapper.selectAll(pageNum * pageSize, pageSize);
        return articles;
    }

    /**
     * 统计文章总数
     * @return
     */
    public int countArticle(){
        return articleMapper.countArticle();
    }
}
